package ThreadDemo;

public class ThreadDemo12 {
    static boolean isQuit = false;
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            while (!isQuit) {
                System.out.println("线程正在运行");
            }
        });
        t.start();
        Thread.sleep(3000);
        isQuit = true;
        System.out.println("让线程结束");
    }
}
